import { readFileSync } from 'fs';
import * as path from 'path'

export default function headerFooterPlugin() {
    return {
        name: 'vite-plugin-header-footer',
        transformIndexHtml(html) {
            const headContent = readFileSync(path.resolve(__dirname, 'src/header.html'), 'utf-8');
            const navContent = readFileSync(path.resolve(__dirname, 'src/nav.html'), 'utf-8');
            const footerContent = readFileSync(path.resolve(__dirname, 'src/footer.html'), 'utf-8');
            return html.replace('<!--header-->', headContent)
                .replace('<!--nav-->', navContent)
                .replace('<!--footer-->', footerContent);
        }
    };
}